import requests
import json

url = "https://chushu.la/api/book/wx/chushula-485889481/pages?isAjax=1"

if __name__ == '__main__':
    params = {
        "type": "year_month",
        "year": 2021,
        "month": 3,
        "value": "v_20213",
    }
    header = {
        # "Accept": "application/json, text/javascript, */*; q = 0.01",
        # "Accept-Encoding": "gzip, deflate, br",
        # "Accept-Language": "zh-CN, zh;q = 0.9",
        # "Cache-Control": "no-cache",
        # "Connection": "keep-alive",
        # "Content-Type": "application/json",
        # "Host": "chushu.la",
        # "Origin": "https://chushu.la",
        # "Pragma": "no-cache",
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Site": "same-origin",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36 SE 2.X MetaSr 1.0",
        # "X-Requested-With": "XMLHttpRequest",
    }
    resp = requests.post(url, data=params, json=True, headers=header).content.decode()
    print(resp)
    # result = json.loads(resp)
    # for k, v in result["pages"]:
    #     if k == 0:
    #         continue
    #     comment = ""
    #     for p in v["data"]["paras"]:
    #         for row in p["rows"]:
    #             comment = comment + row.data
    #
    # print(comment)
